﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using DoAnASP;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["kytu"] != null)
        {
            TimKiemTen(Request.QueryString["kytu"].ToString());
        }
        else
        {
            TimKiemGia();
        }
    }

    public void TimKiemGia()
    {
        
        BUS_SanPham sp = new BUS_SanPham();
        DataTable dt = new DataTable();
        dt = sp.TiemKiemTheoGia(int.Parse(Session["IDGia"].ToString()));
        dtlSanPham.DataSource = dt.DefaultView;
        dtlSanPham.DataBind();
        if (dt.Rows.Count <= 0)
        {
            Session["MaTB"] = 6;
            Response.Redirect("ThongBao.aspx");
        }

    }

    public void TimKiemTen(string kytu)
    {
        BUS_SanPham sp = new BUS_SanPham();
        DataTable dt = new DataTable();
        dt = sp.TiemKiemTheoTen(kytu);
        dtlSanPham.DataSource = dt.DefaultView;
        dtlSanPham.DataBind();        
    }






}